package poradaagreementsparser;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;



/**
 * @author Martin Mihalovic
 */
public class FileLoader {
    private int currentFileIndex = -1;
    private int filesCount;
    String[] fileNames;

    FilenameFilter filter = new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.endsWith(".html");
        }
    };
    
    
    FileLoader(String sourceDir) {
        File dir = new File(sourceDir);
        fileNames = dir.list(filter);
        filesCount = fileNames.length;
        
        for(int i=0; i<filesCount; i++)
            fileNames[i] = sourceDir + fileNames[i];
        
        System.out.println(filesCount + " HTML files found in " + sourceDir);
    }
    
    /*BufferedReader*/String GetNextFile() throws FileNotFoundException {
        currentFileIndex++;
        if(currentFileIndex < filesCount){
//            return new BufferedReader(new FileReader(fileNames[currentFileIndex]));
            return fileNames[currentFileIndex];
        }
        return null;
    }    
}
